package goleetcode

func findMissingAndRepeatedValues(grid [][]int) []int {
	n := len(grid)
	arr := make([]int, n * n + 1)
	for i := range grid {
		for j := range grid[i] {
			arr[grid[i][j]]++
		}
	}
	res := [2]int{}
	for i := 1; i <= n * n; i++ {
		if arr[i] == 2 {
			res[0] = i
		}
		if arr[i] == 0 {
			res[1] = i
		}
	}
	return res[:]
}